import 'package:gameplay_flutter/generated/json/base/json_field.dart';
import 'package:gameplay_flutter/generated/json/moment_entity.g.dart';
import 'dart:convert';

import 'package:gameplay_flutter/lib_basemodel/discover/file_info_entity.dart';
export 'package:gameplay_flutter/generated/json/moment_entity.g.dart';

@JsonSerializable()
class MomentEntity {
  late int id = 0;
  dynamic roomNo;
  dynamic roomName;
  dynamic roomCategoryId;
  dynamic flowType;
  dynamic city;
  String nickName = '';
  dynamic headUrl;
  dynamic micFrameUrl;
  dynamic nicknamePendantUrl;
  dynamic nicknamePendantH5Url;
  dynamic nicknamePendantAdUrl;
  dynamic nicknamePendantIosUrl;
  dynamic gender;
  dynamic file;
  dynamic tag;
  dynamic productId;
  late String title = "";
  late String content = '';
  dynamic platformAuthUrl;
  late bool isLike = false;
  late int isLikes = 0;
  late int likes = 0;
  dynamic router;
  dynamic techVoiceUrl;
  dynamic techVoiceDuration;
  dynamic techDescription;
  dynamic certUrl;
  dynamic danName;
  dynamic categoryHomeIcon;
  dynamic categoryHomeBackgroudIcon;
  dynamic micHeadPortraitsUrlList;
  dynamic roomCategoryName;
  dynamic roomCategoryUrl;
  dynamic roomCategoryNameV1;
  dynamic roomCategoryUrlV1;
  dynamic categoryId;
  dynamic categoryName;
  dynamic identityType;
  late int userId = 0;
  late String userHeadUrl = '';
  dynamic userHeadFrameUrl;
  dynamic userPlatformAuthType;
  dynamic userPlatformAuthName;
  dynamic userPlatformAuthDesc;
  dynamic userPlatformAuthUrl;
  late bool online = false;
  dynamic imId;
  late String userNickname = '';
  dynamic userRemark;
  late int userGender = 0;
  dynamic userAge;
  late int type = 0;
  dynamic productName;
  dynamic productPrice;
  dynamic productMaxPrice;
  dynamic productUnit;
  late String cityName = '';
  int rewards = 0;
  late int comments = 0;
  dynamic clicks;
  late bool isRecommend = false;
  dynamic recommendTime;
  late String createTime = '';
  dynamic status;
  List<FileInfoEntity> files = [];
  dynamic likeUserIds;
  late int isAttention = 0;
  late int memberLevel = 0;
  dynamic memberEmblem;
  dynamic memberExp;
  dynamic categoryIcon;
  dynamic techTags;
  dynamic dan;
  dynamic productVOList;
  dynamic dynamicCommentVOS;
  dynamic nobleExp;
  dynamic nobleRankCode;
  dynamic nobleName;
  dynamic emblemSimpleUrl;
  dynamic emblemUrl;
  dynamic nobleBackgroundUrl;
  dynamic popularityInfo;
  dynamic richerInfo;
  late String timeStr = '';
  late String countryName = '';
  late bool toBlack = false;
  late bool fromBlack = false;
  dynamic toastMsg;
  late int visible = 0;
  late int auditStatus = 0;
  dynamic shareMsg;
  dynamic rewardUserHeadUrlList;
  dynamic topicId;
  late String topicName = "";
  dynamic weightScore;
  late String audioSharePic = '';
  late int officialAccount = 0;
  late int dispatcherType = 0;
  dynamic friendInfo;
  dynamic moodLabelId;
  late int moodNum1 = 0;
  late int moodNum2 = 0;
  late int moodNum3 = 0;
  late int moodNum4 = 0;
  late int moodNum5 = 0;
  late int moodNum6 = 0;
  dynamic userMoodInfo;
  late int dynamicType = 0;
  late bool top = false;
  late List<MomentContentInfoList> contentInfoList = [];
  late String interests = '';
  late List<String> aboutList = [];

  MomentEntity();

  factory MomentEntity.fromJson(Map<String, dynamic> json) =>
      $MomentEntityFromJson(json);

  String? get cover => files.isEmpty
      ? null
      : (type == 1 ? files.first.url : files.first.snapUrl);

  String get titleStr => title.isNotEmpty ? title : content;

  Map<String, dynamic> toJson() => $MomentEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class MomentContentInfoList {
  late String text = '';
  late int type = 0;
  dynamic userId;
  dynamic nickname;
  dynamic imId;
  dynamic userStatus;

  MomentContentInfoList();

  factory MomentContentInfoList.fromJson(Map<String, dynamic> json) =>
      $MomentContentInfoListFromJson(json);

  Map<String, dynamic> toJson() => $MomentContentInfoListToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
